package com.infomanage.enums;


import java.util.HashMap;
import java.util.Map;

/**
 * 职位类型枚举
 * 
 */
public enum PositionType {
	DDZ(1, "大队长"),
	ZW(2, "政委"),
	SJ(14, "书记"),
	ZX(13, "主席"),
	FDDZ(3, "副大队长"),
	ZGCS(12, "总工程师"),
	FZGCS(4, "副总工程师"),
	KZ(5, "科长"),
	FKZ(6, "副科长"),
	KY(15, "科员"),
	ZR(16, "主任"),
	FZR(17, "副主任"),
	BSY(18, "办事员"),
	ZDZ(7, "中队长"),
	FZDZ(8, "副中队长"),
	XDZ(9, "小队长"),
	FXDZ(10, "副小队长"),
	DY(11, "队员"),
	NONE(19, "无");
	
	private int value;
	private String title;

	PositionType(int value, String title) {
		this.value = value;
		this.title = title;
	}

    /**
     * 获取枚举值
     * @return 返回枚举值
     */
	public int value() {
		return this.value;
	}

    /**
     * 获取枚举标题
     * @return 返回枚举的标题
     */
	public String title() {
		return this.title;
	}

	private static Map<String, PositionType> titlefinder;
	static {
		titlefinder = new HashMap<String, PositionType>();
		for (PositionType item : PositionType.values())
			titlefinder.put(item.title(), item);

	}

	private static Map<Integer, PositionType> valuefinder;
	static {
		valuefinder = new HashMap<Integer, PositionType>();
		for (PositionType item : PositionType.values())
			valuefinder.put(new Integer(item.value()), item);

	}

	/**
	 * 按照枚举值查找枚举
	 * 
	 * @param value
	 *            数据类型值对象
	 * @return 返回枚举值对象
	 */
	public static PositionType valueOf(int type) {
		return valuefinder.get(new Integer(type));
	}
	
	/**
	 * 按照枚举标题查找枚举值
	 * 
	 * @param value
	 *            数据类型值对象
	 * @return 返回枚举值对象
	 */
	public static PositionType titleOf(String title) {
		return titlefinder.get(title);
	}
	
	public static PositionType[] getMembers() {
		return new PositionType[] {DDZ, ZW, SJ, ZX, FDDZ, ZGCS, FZGCS, KZ, FKZ, KY, ZR, FZR, BSY, ZDZ, FZDZ, XDZ, FXDZ, DY, NONE};
	}
}
